package com.wanghua.mall.ware.service.impl;

import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanghua.common.utils.PageUtils;
import com.wanghua.common.utils.Query;

import com.wanghua.mall.ware.dao.PurchaseDetailDao;
import com.wanghua.mall.ware.entity.PurchaseDetailEntity;
import com.wanghua.mall.ware.service.PurchaseDetailService;
import org.springframework.util.StringUtils;


@Service
public class PurchaseDetailServiceImpl extends ServiceImpl<PurchaseDetailDao, PurchaseDetailEntity> implements PurchaseDetailService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<PurchaseDetailEntity> queryWrapper = new QueryWrapper<>();
/*        key: this.dataForm.key,
        status: this.dataForm.status,
        wareId: this.dataForm.wareId,*/
        String key = (String) params.get("key");
        if (StringUtils.hasLength(key)) {
            queryWrapper.like("sku_id", key);
        }
        String status = (String) params.get("status");
        if (StringUtils.hasLength(status)) {
            queryWrapper.like("status", status);
        }
        String wareId = (String) params.get("wareId");
        if (StringUtils.hasLength(wareId)) {
            queryWrapper.like("ware_id", wareId);
        }
        IPage<PurchaseDetailEntity> page = this.page(
                new Query<PurchaseDetailEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}